package com.igeekhome.controller;

import com.igeekhome.pojo.DNetwork;
import com.igeekhome.pojo.SWarehouse;
import com.igeekhome.service.INetworkService;
import com.igeekhome.service.IWarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@RequestMapping("/page")
@Controller
public class WarehouseController {

    @Autowired
    private IWarehouseService warehouseService;

    @Autowired
    private INetworkService networkService;

    /**
     * 仓库维护
     */
    @RequestMapping("/warehouseList")
    public String warehouse(){
        return "pages/data/warehouse/warehouse";
    }


    @RequestMapping("/editWarehouse/{id}")
    public String editWarehouse(@PathVariable("id") Integer id, Model model) {
        SWarehouse sWarehouse = warehouseService.selectByPrimaryKey(id);
        List<DNetwork> dNetworks = networkService.selectAll();
        model.addAttribute("networkList",dNetworks);
        model.addAttribute("sWarehouse",sWarehouse);
        return "pages/data/warehouse/addWarehouse";
    }

    @RequestMapping("/addWarehouse")
    public String addWarehouse(Model model) {
        List<DNetwork> dNetworks = networkService.selectAll();
        model.addAttribute("networkList",dNetworks);
        return "pages/data/warehouse/addWarehouse";
    }
}
